/*
 * Created on 03/06/2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package br.ufal.tci.nexos.arcolive.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;

import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;

/**
 * @author Marcio
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class UsersManager extends JInternalFrame {
	
	private JPanel mainPanel;
	private JPanel upPanel;
	private JPanel downPanel;
	
	private JList servicesList;
	private JScrollPane listScroll;
	private JPanel buttonsPanel;
	private JButton buttonRemove;
	private JButton buttonAdvice;
	private JButton buttonConnection;

	private JLabel servicesLabel;
	private JComboBox servicesCombo;

	public UsersManager() {
		initComponents();
	}
	
	public void initComponents() {
		mainPanel = new JPanel();
		
		setIconifiable(true);
		setClosable(true);
        setTitle("Gerenciamento de Usuários");
		
		upPanel = new JPanel();
		downPanel = new JPanel();
		
		servicesLabel = new JLabel("Instâncias de Serviços: ");
		
		servicesCombo = new JComboBox();
		servicesCombo.setPreferredSize(new Dimension(225,20));
		
		upPanel.setLayout(new FlowLayout());
		upPanel.add(servicesLabel);
		upPanel.add(servicesCombo);
		
		servicesList = new JList(new DefaultListModel());
		servicesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		
		listScroll = new JScrollPane(this.servicesList);
		
		buttonRemove = new JButton(new ImageIcon(UsersManager.class.getResource("icons/Remover.png")));
		buttonRemove.setPreferredSize(new Dimension(19, 19));
		
		buttonAdvice = new JButton(new ImageIcon(UsersManager.class.getResource("icons/Aviso.png")));
		buttonAdvice.setPreferredSize(new Dimension(19, 19));

		buttonConnection = new JButton(new ImageIcon(UsersManager.class.getResource("icons/Conexao.png")));
		buttonConnection.setPreferredSize(new Dimension(19, 19));
		
		buttonsPanel = new JPanel();
		buttonsPanel.setLayout(new GridLayout(6,1));
		buttonsPanel.add(this.buttonRemove);
		buttonsPanel.add(this.buttonAdvice);
		buttonsPanel.add(this.buttonConnection);
		
		downPanel.setPreferredSize(new Dimension(400,150));
		downPanel.setLayout(new BorderLayout());
		downPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), " Instancias do Serviço: "));
		downPanel.add(listScroll, BorderLayout.CENTER);
		downPanel.add(buttonsPanel, BorderLayout.WEST);
		
		mainPanel.add(upPanel, BorderLayout.NORTH);
		mainPanel.add(downPanel, BorderLayout.CENTER);

		/* Para o print screen */
		
		servicesCombo.addItem("Aula de Inteligência Artificial 1");
		
		((DefaultListModel)servicesList.getModel()).addElement("Marcinho");
		((DefaultListModel)servicesList.getModel()).addElement("Leandro Melo de Sales");
		((DefaultListModel)servicesList.getModel()).addElement("Doctor Vigia");
		((DefaultListModel)servicesList.getModel()).addElement("Marobinha");
		
		/* fim */
		
		getContentPane().add(mainPanel);
		
        pack();
        Desktop.getInstance().getDesktopPane().add(this);
		setSize(450, 240);
		show();
	}

}